------------------------------------------------------------------------------------------------------------------------------------
      name:  plog_843
       log:  /accounts/projects/jr_ra/GRscarring/erratum/programs/analysis/fig_ur.log
  log type:  text
 opened on:  27 Nov 2024, 17:52:01

. * Figure 1 -Employment and unemployment. Published UR, and prime-age non-employment rate 
. 
. *Modification history:
. * 4/14/2020: Exclude 2020
. *************************************************************************************************************** 
. clear

. cap project, doinfo

. if _rc==0 {
.         local pdir "`r(pdir)'"                                                      // the project's main dir.
.         local dofile "`r(dofile)'"                                                  // do-file's stub name
.         local sig {bind:{hi:[`dofile'.dta. RP : `dofile'.do, `c(current_date)']}}       // a signature in notes
.         local doasproject=1
. }

. else {
.         local pdir "~/GRscarring"
.         local dofile "fig_ur"
.         local doasproject=0
. }

. 
. set more off

. local rootdir "`pdir'"

. local thisdir "`pdir'"

. 
. local scratch "`pdir'/scratch"

. local rawdata "`pdir'/rawdata"

. local output "`pdir'/results"

. 
. if `doasproject'==1 {
.         project, uses("`scratch'/unrate_national.dta")
project GRscar_erratum > do-file uses: "/scratch/public/jr_ra/GRscarring2024/erratum/scratch/unrate_national.dta" filesig(1052845851
> :51188)
.         project, uses("`scratch'/extractcps.dta.gz")
project GRscar_erratum > do-file uses: "/scratch/public/jr_ra/GRscarring2024/erratum/scratch/extractcps.dta.gz" filesig(1117482818:1
> 425161591)
. }

. 
. set scheme s1color

. 
. ** Create Prime Age  Non Employment 
. !zcat `scratch'/extractcps.dta.gz > `scratch'/extractcps.dta 


. use`scratch'/extractcps.dta

. use age empl yearmo wgt_composite using `scratch'/extractcps.dta

. gen prime=1 if age>24 & age<55
(24,513,217 missing values generated)

. keep if prime==1
(24,513,217 observations deleted)

. collapse (mean) empl [aw=wgt_composite], by(yearmo)

. gen nonemploy_r = (1 - empl)

. 
. 
. *Simple seasonal adjustment
. gen year=year(dofm(yearmo))

. gen mon=month(dofm(yearmo))

. foreach v of varlist  nonemploy_r {
  2.   areg `v' i.year, a(mon)
  3.   local int=_b[_cons]
  4.   predict monfx, d
  5.   gen `v'_sa=`v'-monfx
  6.   drop monfx
  7. }

Linear regression, absorbing indicators             Number of obs     =    492
Absorbed variable: mon                              No. of categories =     12
                                                    F(40, 440)        = 450.86
                                                    Prob > F          = 0.0000
                                                    R-squared         = 0.9768
                                                    Adj R-squared     = 0.9741
                                                    Root MSE          = 0.0036

------------------------------------------------------------------------------
 nonemploy_r | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
        year |
       1980  |   .0036911   .0014857     2.48   0.013     .0007712     .006611
       1981  |  -.0005208   .0014857    -0.35   0.726    -.0034407    .0023991
       1982  |   .0111568   .0014857     7.51   0.000     .0082369    .0140767
       1983  |   .0087869   .0014857     5.91   0.000      .005867    .0117068
       1984  |  -.0121205   .0014857    -8.16   0.000    -.0150404   -.0092006
       1985  |   -.020651   .0014857   -13.90   0.000    -.0235709   -.0177311
       1986  |  -.0268768   .0014857   -18.09   0.000    -.0297967   -.0239569
       1987  |  -.0370458   .0014857   -24.94   0.000    -.0399657   -.0341259
       1988  |  -.0450968   .0014857   -30.35   0.000    -.0480167   -.0421769
       1989  |  -.0527501   .0014857   -35.51   0.000      -.05567   -.0498302
       1990  |  -.0498508   .0014857   -33.55   0.000    -.0527707   -.0469309
       1991  |  -.0394725   .0014857   -26.57   0.000    -.0423924   -.0365526
       1992  |  -.0363528   .0014857   -24.47   0.000    -.0392727   -.0334329
       1993  |  -.0390638   .0014857   -26.29   0.000    -.0419837   -.0361439
       1994  |  -.0459288   .0014857   -30.91   0.000    -.0488487    -.043009
       1995  |  -.0509413   .0014857   -34.29   0.000    -.0538612   -.0480214
       1996  |  -.0555344   .0014857   -37.38   0.000    -.0584543   -.0526145
       1997  |   -.061972   .0014857   -41.71   0.000    -.0648919   -.0590521
       1998  |  -.0643365   .0014857   -43.30   0.000    -.0672564   -.0614166
       1999  |  -.0674053   .0014857   -45.37   0.000    -.0703252   -.0644854
       2000  |  -.0682045   .0014857   -45.91   0.000    -.0711244   -.0652846
       2001  |  -.0589989   .0014857   -39.71   0.000    -.0619188    -.056079
       2002  |  -.0465314   .0014857   -31.32   0.000    -.0494513   -.0436115
       2003  |   -.041495   .0014857   -27.93   0.000    -.0444149   -.0385751
       2004  |  -.0431018   .0014857   -29.01   0.000    -.0460217    -.040182
       2005  |  -.0466451   .0014857   -31.40   0.000     -.049565   -.0437253
       2006  |  -.0513992   .0014857   -34.60   0.000    -.0543191   -.0484793
       2007  |  -.0524303   .0014857   -35.29   0.000    -.0553502   -.0495104
       2008  |  -.0441222   .0014857   -29.70   0.000    -.0470421   -.0412023
       2009  |  -.0110181   .0014857    -7.42   0.000     -.013938   -.0080982
       2010  |  -.0041973   .0014857    -2.83   0.005    -.0071172   -.0012774
       2011  |   -.004453   .0014857    -3.00   0.003    -.0073729   -.0015331
       2012  |  -.0106024   .0014857    -7.14   0.000    -.0135223   -.0076825
       2013  |  -.0122397   .0014857    -8.24   0.000    -.0151596   -.0093198
       2014  |  -.0202933   .0014857   -13.66   0.000    -.0232132   -.0173734
       2015  |  -.0256923   .0014857   -17.29   0.000    -.0286122   -.0227724
       2016  |  -.0325748   .0014857   -21.93   0.000    -.0354947   -.0296549
       2017  |  -.0394802   .0014857   -26.57   0.000       -.0424   -.0365603
       2018  |  -.0469473   .0014857   -31.60   0.000    -.0498672   -.0440274
       2019  |  -.0529041   .0014857   -35.61   0.000     -.055824   -.0499842
             |
       _cons |   .2532854   .0010505   241.10   0.000     .2512207    .2553501
------------------------------------------------------------------------------
F test of absorbed indicators: F(11, 440) = 45.626            Prob > F = 0.000

. 
. * 7 months Smoothing         
. tsset yearmo

Time variable: yearmo, 1979m1 to 2019m12
        Delta: 1 month

. foreach v of varlist nonemploy_r_sa {
  2.   gen     `v'_m7=100*((4*`v' + 3*L.`v' + 2*L2.`v' + 1*L3.`v'+ 3*F.`v'+ 2*F2.`v' + 1*F3.`v')/16)
  3.   replace `v'_m7=100*((4*`v' + 3*L.`v' + 2*L2.`v' + 1*L3.`v')/10) if F.`v'==.
  4.   replace `v'_m7=100*((4*`v' + 3*F.`v' + 2*F2.`v' + 1*F3.`v')/10) if L.`v'==.
  5. }
(6 missing values generated)
(1 real change made)
(1 real change made)

. 
. tempfile nonempl

. save `nonempl'
file /tmp/St2868349.000004 saved as .dta format

. 
. ** Merge to first dataset 
. merge 1:1 yearmo using `scratch'/unrate_national, nogen
(variable yearmo was int, now double to accommodate using data's values)

    Result                      Number of obs
    -----------------------------------------
    Not matched                           387
        from master                         0  
        from using                        387  

    Matched                               492  
    -----------------------------------------

. 
. keep if yearmo>=ym(1981, 7)
(414 observations deleted)

. gen recession=(yearmo>=ym(1981,7) & yearmo<=ym(1982,11)) | (yearmo>=ym(1990,7) & yearmo<=ym(1991,3)) | ///
>               (yearmo>=ym(2001,3) & yearmo<=ym(2001,11)) | (yearmo>=ym(2007,12) & yearmo<=ym(2009,6))

. 
. keep if yearmo>=ym(1989,1)
(90 observations deleted)

. keep if yearmo<=ym(2019,12)
(3 observations deleted)

. 
. gen nonemploy_r_copy=nonemploy_r_sa_m7-18
(2 missing values generated)

. gen altrecession=recession*8

. 
. ** Figure 1 - Figure 1. Employment and unemployment. Published UR, and prime-age non-employment rate 
. twoway area altrecession yearmo, yaxis(1) color(gs13)  || ///
>  line  nonemploy_r_copy yearmo, yaxis(1) ytitle("Non-employment rate (seasonally adjusted)", height(4) axis(1)) ylabel(0 "18" 2 "2
> 0" 4 "22" 6 "24" 8 "26", axis(1))  || ///
>  line  ur_nat_s yearmo, lpattern(dash) yaxis(2) ytitle("Unemployment rate (seasonally adjusted)", axis(2)) ylabel(0 (2) 10, axis(2
> )) || ///
> , xlabel(366 "1990" 426 "1995" 486 "2000" 546 "2005" 606 "2010" 666 "2015" 726 "2020") ///
>  xtitle("")  legend(order(2 "Non-employment (l. axis)" 3 "Unemployment rate (r. axis)") size(small)) title(" Unemployment and prim
> e-age non-employment", size(medsmall))  ///
>   saving("`output'/fig_ur.gph", replace)
file /accounts/projects/jr_ra/GRscarring/erratum/results/fig_ur.gph saved

.   
. save `scratch'/fig_ur.dta, replace
(file /accounts/projects/jr_ra/GRscarring/erratum/scratch/fig_ur.dta not found)
file /accounts/projects/jr_ra/GRscarring/erratum/scratch/fig_ur.dta saved

. ! rm `scratch'/extractcps.dta


. 
.   
.  if `doasproject'==1 {
.         project, creates(`output'/fig_ur.gph)
project GRscar_erratum > do-file creates: "results/fig_ur.gph" filesig(2156250526:21386)
.         project, creates(`scratch'/fig_ur.dta)
project GRscar_erratum > do-file creates: "/scratch/public/jr_ra/GRscarring2024/erratum/scratch/fig_ur.dta" filesig(3758749835:63094
> )
. } 

. 
end of do-file
      name:  plog_843
       log:  /accounts/projects/jr_ra/GRscarring/erratum/programs/analysis/fig_ur.log
  log type:  text
 closed on:  27 Nov 2024, 17:55:01
------------------------------------------------------------------------------------------------------------------------------------
